<?php

/*
 * This file is part of the Dektrium project.
 *
 * (c) Dektrium project <http://github.com/dektrium>
 *
 * For the full copyright and license information, please view the LICENSE.md
 * file that was distributed with this source code.
 */

namespace backend\modules\Sys\modules\Rbac\controllers;

use backend\models\c2\entity\rbac\Route;
use dektrium\rbac\controllers\PermissionController as BaseController;
use Yii;

/**
 * @author Dmitry Erofeev <dmeroff@gmail.com>
 */
class PermissionController extends BaseController
{
    protected $modelClass = 'backend\models\c2\entity\rbac\Permission';

    /**
     * @param $name
     * @return int
     * @throws \yii\base\InvalidConfigException
     * @throws \yii\web\NotFoundHttpException
     */
    public function actionEditColumn($name)
    {
        $item = $this->getItem($name);
        $model = \Yii::createObject([
            'class' => $this->modelClass,
            'scenario' => 'update',
            'item' => $item,
        ]);
        $model->description = \Yii::$app->request->post('description');
        if ($model->save()) {
            return 0;
        }

        return 1;
    }

}